package com.zbkj.crmeb.store.dao;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.utils.dto.StoreProductQueryDto;
import com.zbkj.crmeb.chant.request.ChannelProductRequest;
import com.zbkj.crmeb.chant.vo.ChannelProductVo;
import com.zbkj.crmeb.export.vo.ProductExcelVo;
import com.zbkj.crmeb.front.request.IndexStoreProductSearchRequest;
import com.zbkj.crmeb.front.request.ProductRequest;
import com.zbkj.crmeb.store.dto.product.StoreProductQueryDTO;
import com.zbkj.crmeb.store.model.StoreProduct;
import com.zbkj.crmeb.store.model.StoreProductDraft;
import com.zbkj.crmeb.store.request.StoreProductSearchRequest;
import com.zbkj.crmeb.store.response.StoreProductApiResponse;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 商品表 Mapper 接口
 * </p>
 *
 * @author Mr.Zhang
 * @since 2020-05-27
 */
public interface StoreProductDao extends BaseMapper<StoreProduct> {
    int reSortProduct();

    /**
     * 渠道商品列表
     * @param reqParam
     * @return
     */
    List<ChannelProductVo> selectChannelProductList(ChannelProductRequest reqParam);

    List<StoreProduct> selectProductList(IndexStoreProductSearchRequest request);
    
    /**
     * 查询对外api需要的商品字段格式
     * @Description:  
     * @author daigb 
     * @param @param request
     * @param @return
     * @return List<StoreProduct>
     * @throws
     */
    List<StoreProductApiResponse> selectApiProductList(IndexStoreProductSearchRequest request);

    /**
     * 
     * @author cyz
     * @date 2021/4/1 14:40
     * @param request 
     * @return com.zbkj.crmeb.store.model.StoreProduct
     */
    StoreProduct selectProductOne(ProductRequest request);

    StoreProductDraft selectDraftProductOne(ProductRequest request);

    /**
     *
     * @author cyz
     * @date 2021/4/6 16:51
     * @param reqParam
     * @return java.util.List<com.zbkj.crmeb.chant.vo.ChannelProductVo>
    */
    List<ChannelProductVo> selectNewChannelProductList(ChannelProductRequest reqParam);

    /**
     * 
     * @author cyz
     * @date 2021/4/9 11:30
     * @param request
     * @return java.util.List<com.zbkj.crmeb.store.model.StoreProduct>
     */
    List<StoreProduct> selectZoneProductList(ProductRequest request);

    /**
     * 
     * @author cyz
     * @date 2021/4/12 10:49
     * @param reqParam
     * @return java.util.List<com.zbkj.crmeb.chant.vo.ChannelProductVo>
     */
    List<ChannelProductVo> selectChannelProductListByPushFlag(ChannelProductRequest reqParam);
    
    /**
     * 实时更新库存
     * @Description:  
     * @author daigb 
     * @param @param productId
     * @param @param stock
     * @param @return
     * @return Integer
     * @throws
     */
    Integer subProductStock(@Param("productId") Integer productId, @Param("stock") Integer stock);

    /**
     * 更新国际编码
     * @param productId
     * @param keyword
     * @return
     */
    Integer updateKeyword(@Param("productId") Integer productId, @Param("keyword") String keyword);

    /**
     * 用新的季节替换老的季节
     * @param oldSeasonCode
     * @param newSeasonCode
     * @return
     */
    Integer repairSeasonCode(@Param("oldSeasonCode") String oldSeasonCode, @Param("newSeasonCode") String newSeasonCode);
    
    void ofProductSuppliersCount();
    
    void calcProductSuppliersCount();
    
    void delProductException();
    
    void autoDownProductTask(@Param("tableNameMp") String tableNameMp, @Param("merId") Integer merId, @Param("suppliersIds") JSONArray suppliersIds, @Param("brandIds") JSONArray brandIds);

    List<ProductExcelVo> selectListByCondition(StoreProductSearchRequest request);

    List<ProductExcelVo> selectExportList(@Param("targetSql") String targetSql, @Param("ew")HashMap<String, Object> ew);

    List<ProductExcelVo> selectExportList1(@Param("targetSql") String targetSql, @Param("ew")HashMap<String, Object> ew, @Param("attrValueIds") List<String> attrValueIds);

    /**
     * 服务商商品
     * @param request
     * @return
     */
    List<StoreProduct> selectAgentProductList(StoreProductSearchRequest request);

    /**
     * 统计服务商商品数量
     * @param request
     * @return
     */
    Long countAgentStoreProduct(StoreProductSearchRequest request);

    /**
     * 查询指定供应商品牌
     * @return
     */
    List<Integer> selectBrandIdsBySupplierIds(@Param("supplierIdList") List<Integer> supplierIdList);

    List<StoreProduct> list(StoreProductQueryDTO storeProductQueryDTO);
    /**
     * 商品
     * @param queryDto
     * @return
     */
    List<StoreProduct> queryProductList(StoreProductQueryDto queryDto);
    /**
     * 商品
     * @param queryDto
     * @return
     */
    List<StoreProduct> queryProductListV2(StoreProductQueryDto queryDto);


    /**
     * 查询君梦需要更新的商品信息
     */
    List<StoreProduct> selectNeedUpdateStockProducts(StoreProductQueryDto queryDto);
}
